package com.company.OfferGuide;

import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;

public class 队列的最大值 {

    Queue<Integer> queue;
    PriorityQueue<Integer> maxValue;

    public void MaxQueue() {
        queue = new LinkedList<>();
        maxValue = new PriorityQueue<>((o1,o2) -> {
            return o2 - o1;
        });
    }

    public int max_value() {
        if (maxValue.isEmpty()) return -1;
        return maxValue.peek();
    }

    public void push_back(int value) {
        queue.offer(value);
        maxValue.offer(value);
    }

    public int pop_front() {
        if (queue.size() == 0) return -1;
        maxValue.remove(queue.peek());
        return queue.poll();
    }

}
